<template>
    <div>
        <h3 v-on:click="clickOnClick">{{ title }}</h3>
        <span v-for="id in items" :style="{ opacity: (id == cur ? 1 : 0)}">{{ id }}</span>
    </div>
</template>
<script type="application/lua" lang="lua">
local js = require "js"
local global = js.global
local console = global.console
loader.Export({
    data = function()
        return obj{
            num = 1;
            items = A{0,1,2,3,4,5,6,7,8,9};
            title = "我也可以点击xxx";
            cur = 0;
        }
    end;
    mounted = function(self)

        global:setTimeout(self.count_down,0)

    end;
    methods = obj{
        count_down = function(self)
            self.cur = self.cur + 1;

            if self.cur > 9 then
                self.cur = 0
            end

            global:setTimeout(self.count_down,100)
        end;
        clickOnClick = function(self)
            self.num = self.num + 1;
            self.title = '第' .. self.num .. '次点击x';
        end;
    };
})
</script>
<style>
.btn {
    display: block;
}
</style>